package com.yaowk.web.system.controller;

import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import com.yaowk.api.system.model.Permission;
import com.yaowk.api.system.service.IPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/permission")
@Api(tags = "权限管理")
public class PermissionController {

    @Autowired
    private IPermissionService service;

    @GetMapping()
    @ApiOperation("权限列表")
    public PageResp<Permission> list(PageReq pageReq) {
        return service.findAll(pageReq);
    }

    @PostMapping()
    @ApiOperation("保存权限")
    public Permission save(Permission permission) {
        return service.simpleSave(permission);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除权限")
    public void delete(@PathVariable Integer id) {
        service.deleteById(id);
    }

}
